{*
  Object Pascal telephone string manipulation routines
  @Author  Maciej Zagozda (1998-2008)
  @Licence Microsoft Reciprocal License (Ms-RL)
  @Website http://www.codeplex.com/intelitechdelphirtns/
  @Version 2008/04/20 Added documentation support
}

unit PhoneRoutines;

interface

uses
  Classes,
  Controls,
  ComObj,
  Dialogs,
  Forms,
  Graphics,
  Messages,
  SysUtils,
  Windows;

function GetAreaPhonePrefix( strnAreaName: AnsiString ): AnsiString;
function GetCountryPhonePrefix( strnCountryName: AnsiString ): AnsiString;
function GetPhonePrefix( strnCountryName, strnAreaName: AnsiString ): AnsiString;

implementation

uses
  StringRoutines;


//_____________________________________________________________________________

function GetCountryPhonePrefix( strnCountryName: AnsiString ): AnsiString;
begin

  strnCountryName := UpperCase( strnCountryName );
  Result := '';

  if ( strnCountryName = 'POLAND' ) or ( strnCountryName = 'POLEN' ) or ( strnCountryName = 'POLSKA' ) then Result := '+48';

end;

//_____________________________________________________________________________

function GetAreaPhonePrefix( strnAreaName: AnsiString ): AnsiString;
begin

  strnAreaName := UpperCase( strnAreaName );
  Result := '';

  if ( strnAreaName = 'STETTIN' ) or ( strnAreaName = 'SZCZECIN' ) then  Result := '91';

end;

//_____________________________________________________________________________

function GetPhonePrefix( strnCountryName, strnAreaName: AnsiString ): AnsiString;
var
  strnResult: AnsiString;
begin
  strnResult := '';
  strnResult := strnResult + ' ' + GetCountryPhonePrefix( strnCountryName );
  strnResult := strnResult + ' ' + GetAreaPhonePrefix( strnAreaName );
  strnResult := '(' + Trim( strnResult ) + ')';

  Result := strnResult;

end;//if

end.



